package com.itheima.spring_demo.controller;

import com.itheima.spring_demo.service.UserService;
import com.itheima.spring_design.context.ApplicationContext;
import com.itheima.spring_design.context.support.ClassPathXmlApplicationContext;

/**
 * 使用自定义SpringIOC测试
 */
public class UserController2 {

    public static void main(String[] args) throws Exception {
        // 1.创建spring的容器对象
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        // 2.从容器对象中获取userService对象
        UserService userService = applicationContext.getBean("userService", UserService.class);
        // 3.调用userService的方法进行业务逻辑处理
        userService.add();
    }
}
